package cn.edu.swu.lxy.rolems

import android.content.Context
import android.database.sqlite.SQLiteDatabase
import android.database.sqlite.SQLiteOpenHelper
import android.util.Log
import android.widget.Toast

class MyDatabaseHelperRole(private val context: Context, name: String, version: Int) :
    SQLiteOpenHelper(context, name, null, version) {
    private val createRole = "create table MyRoles (" +
            " id integer primary key autoincrement," +
            " name text," +
            " attr text," +
            " ps text," +
            " pic int)"
    override fun onCreate(db: SQLiteDatabase) {
        db.execSQL(createRole)
        Toast.makeText(context, "Create succeeded", Toast.LENGTH_LONG).show()
    }
    override fun onUpgrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
        db.execSQL("drop table if exists MyRoles")
        Log.d(".Roles","drop old db")
        onCreate(db)

    }
}
